package com.kylingroup.JavaFX.TreeView;

import java.io.IOException;
import java.io.InputStream;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.fxml.JavaFXBuilderFactory;
import javafx.scene.Group;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class FileBrowser extends Application {
    public static Stage stage=null;
    
    @Override
    public void start(Stage stage) throws Exception {
        this.stage=stage;
        stage.setTitle("File browser");
        stage.setScene(new Scene(createContent()));
        stage.show();
    }

    public static void main(String[] args) {
        Application.launch(args);
    }

    public Parent createContent() {
        Group root = new Group();
        BorderPane maincontent = null;
        FXMLLoader loader = new FXMLLoader();
        InputStream in = FileBrowser.class.getResourceAsStream("FileBrowser.fxml");
        loader.setBuilderFactory(new JavaFXBuilderFactory());
        loader.setLocation(FileBrowser.class.getResource("FileBrowser.fxml"));

        try {
            maincontent = (BorderPane) loader.load(in);
            FileBrowserController maincontrol = (FileBrowserController) loader.getController();

        } catch (IOException ex) {
            ex.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
        root.getChildren().removeAll();
        root.getChildren().addAll(maincontent);
        return root;
    }
}
